package acm.pta;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Map<Integer,Node> map=new HashMap<>();
        Reader sc=new Reader();
        int n = sc.nextInt();
        while (n-- > 0) {
            int id=sc.nextInt();
            int pid= sc.nextInt();
            int mid= sc.nextInt();
            int[] children=new int[sc.nextInt()];
            for (int i = 0; i < children.length; i++) {
                children[i]= sc.nextInt();
            }
            int house= sc.nextInt();
            int area= sc.nextInt();
            Node curr = new Node(id, house, area, pid, mid);
            map.put(id,curr);
            if (pid!=-1) {
                Node parent = map.getOrDefault(pid,new Node(pid));
                map.put(pid,parent);
            }
            if (mid!=-1) {
                Node mother = map.getOrDefault(mid,new Node(mid));
                map.put(mid,mother);
            }
            for (int c : children) {
                Node child = map.getOrDefault(c, new Node(c, id, -1));
                //只有一种情况需要这样添加，即孩子没有作为父母出现过，但它的父母都出现过
                if (child.pid!=id){
                    child.mid=id;
                }
                map.put(c,child);
            }
        }
        fun(map);
    }

    public static void fun(Map<Integer,Node> map){
        UnionFindSet unionFindSet=new UnionFindSet(map.values());
        Collection<Node> values = map.values();
        for (Node v : values) {
            Node m = map.get(v.mid);
            Node p = map.get(v.pid);
            if (p!=null) {
                unionFindSet.union(v,p);
            }
            if (m!=null){
                unionFindSet.union(v,m);
            }
        }
        Set<Node> set = unionFindSet.set;   //所有的父节点
        System.out.println(set.size());
        set.stream().sorted(Main::compare).forEach(Main::print);
    }
    public static void print(Node o){
        System.out.println(String.format("%04d %d %.3f %.3f",o.id,o.count,o.getAvgHouse(),o.getAvgArea()));
    }
    public static int compare(Node o1,Node o2){
        double o1Avg = o1.getAvgArea();
        double o2Avg = o2.getAvgArea();
        if (o1Avg==o2Avg) {
            return o1.id-o2.id;
        }
        return o1Avg<o2Avg?1:-1;
    }
    static class UnionFindSet{
        Map<Node,Node> map=new HashMap<>();
//        Node[] map=new Node[10000]
        /**
         * 存放集合的根节点
         */
        Set<Node> set=new HashSet<>();

        public UnionFindSet() {
        }

        public UnionFindSet(Collection<Node> nodes) {
            nodes.forEach(o->{
                set.add(o);
                map.put(o,o);
            });
        }

        public Node find(Node o){
            Node parent = map.get(o);
            if (parent==null||parent==o){
                return o;
            }
            parent= find(parent);
            map.put(o,parent);
            return parent;
        }
        public void union(Node a,Node b){
            if (!map.containsKey(a)){
                init(a);
            }
            if (!map.containsKey(b)){
                init(b);
            }
            Node parentA = find(a);
            Node parentB = find(b);
            if (parentA.equals(parentB)) {
                return;
            }
            if (parentA.id<parentB.id){
                merge(parentA,parentB);
            }else {
                merge(parentB,parentA);
            }
        }
        private void merge(Node o1,Node o2){
            map.put(o2,o1);
            set.remove(o2);
            o1.area+=o2.area;
            o1.count+=o2.count;
            o1.house+=o2.house;
        }
        public void init(Node o){
            if (map.containsKey(o)){
                return;
            }
            map.put(o,o);
            set.add(o);
        }
    }
    static class Node {
        int id=-1;
        int house;
        int area;
        int count=1;
        int pid=-1;
        int mid=-1;

        public Node(Integer id) {
            this.id = id;
        }
        public Node(Integer id,Integer pid,Integer mid) {
            this.id = id;
            this.pid=pid;
            this.mid=mid;
        }
        public Node(Integer id, Integer house, Integer area,Integer pid,Integer mid) {
            this.id = id;
            this.house = house;
            this.area = area;
            this.pid = pid;
            this.mid = mid;
        }
        public double getAvgHouse(){
            return 1.0*house/count;
        }
        public double getAvgArea(){
            return 1.0*area/count;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Node node = (Node) o;
            return Objects.equals(id, node.id);
        }

        @Override
        public int hashCode() {
            return Objects.hash(id);
        }

        @Override
        public String toString() {
            return "Node{" +
                    "id=" + id +
                    '}';
        }
    }
    static class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
//
//        public double nextDouble(){
//            return Double.parseDouble(next());
//        }
    }
}
